<template>
  <div>
    <div class="home">
      <div class="w">
        <div class="search">
          <!--  suffix-icon="el-icon-search" -->
          <el-input
            placeholder="请输入想搜索的地区"
            v-model="info"
            @keydown.enter.native="search"
          >
          </el-input>
          <i class="el-icon-search searchIcon" @click="search"></i>
          <i class="after"></i>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { searchInfo } from "@/api";
export default {
  data() {
    return {
      info: "",
    };
  },
  methods: {
    //搜索
    async search() {
      console.log(this.info);
      //因为要处理空白搜索全部，所以在这里进行请求，在路由传值给下一个页面
        const {data} = await searchInfo({ title_contains: this.info });
        this.$router.push({
          path:'/list',
          query:{
            data
          }
        })
      }
    },
};
</script>
<style lang="less" scoped>
.home {
  height: 700px;
  background: url("~@/assets/bg.jpg") no-repeat center;
  .w {
    height: 700px;
    position: relative;
  }
}
.search {
  position: absolute;
  width: 550px;
  height: 50px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /deep/.el-input__inner {
    width: 550px;
    height: 50px;
    line-height: 50px;
    font-size: 16px;
    border: none;
    border-radius: 0 4px 4px;
  }
  /deep/.el-icon-search {
    margin: 5px 5px 0 0;
    color: #000;
    font-size: 26px;
    font-weight: 700;
  }
  &::after {
    content: "搜索";
    position: absolute;
    top: -40px;
    left: 0;
    color: #333;
    width: 80px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    background-color: #eee;
    border-radius: 4px 4px 0 0;
  }
  .after {
    position: absolute;
    top: -40px;
    left: 65px;
    width: 20px;
    height: 40px;
    border-top-right-radius: 4px;
    transform: skewX(15deg);
    background-color: #eee;
  }
  ::-webkit-input-placeholder {
    color: #666;
  }
  .searchIcon{
    position: absolute;
    top: 7px;
    right: 5px;
    cursor: pointer;
  }
}
</style>